<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <table>
        <tr>
            <td>选举人</td>
            <td>票数</td>
            <td>操作</td>
        </tr>
        <tr>
            <td>jack</td>
            <td class="num1">0</td>
            <td><button id="btn1">投票</button></td>
        </tr>
        <tr>
            <td>alex</td>
            <td class="num2">10</td>
            <td><button id="btn2">投票</button></td>
        </tr>
    </table>

    <script>
        let btn1 = document.querySelector('#btn1');
        let btn2 = document.querySelector('#btn2');
        // let num1 = document.querySelector('.num1');
        // let num2 = document.querySelector('.num2')
        // btn1.addEventListener('click', () => {
        //     num1.innerHTML++;
        // });
        // let timer = null;
        // btn2.addEventListener('click', () => {

        //     if (timer == null) {
        //         timer = setTimeout(() => {
        //             timer = null;
        //             num2.innerHTML++;
        //         }, 1000);
        //     }
        // })

        // ---------------------------------

        let tr1 = btn1.parentNode.parentNode;
        let tr2 = btn2.parentNode.parentNode;
        btn1.addEventListener('click', () => {
            tr1.children[1].innerHTML++;
        })
        let timer = null;
        btn2.addEventListener('click', () => {
            if (timer == null) {
                timer = setTimeout(() => {
                    timer = null;
                    tr2.children[1].innerHTML++;
                }, 1000);
            }
        })
    </script>
</body>

</html>